# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=binproxy
pkgver=8.d02fce9
pkgrel=14
groups=('blackarch' 'blackarch-proxy' 'blackarch-networking')
pkgdesc='A proxy for arbitrary TCP connections.'
arch=('any')
license=('custom:unknown')
depends=('ruby' 'ruby-bundler')
makedepends=('git' 'libxslt')
url='https://github.com/nccgroup/BinProxy/'
source=("$pkgname::git+https://github.com/nccgroup/BinProxy.git")
install="$pkgname.install"
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  sed -i 's|"bundler", "~> 1.3"|"bundler"|g' "$pkgname.gemspec"
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md TODO TODO.old

  cp --no-preserve=ownership -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec bundle exec bin/$pkgname "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

